using System.Collections;
using System.Html;
using System.Runtime.CompilerServices;
using Awaiter;
using Nsb.Classes;
using Yoshi.Classes;
using jQueryApi;

namespace YesPlayLove.Classes
{
    [IgnoreNamespace]
    public class YoshiFlow : YoshiPage
    {
        [AlternateSignature]
        protected extern void PlayAliasAw(Await awp);

        protected void PlayAliasAw(Await awp, Dictionary options)
        {
            PlayAlias(options).AppendTo(PageCluster);
            awp.Done();
        }


        protected void MultipleChoiceAw(Await awp, Dictionary question)
        {
            string name = (string)question["name"] ?? Formulas.NewId;

            MultipleChoice(name, question).AppendTo(PageCluster);

            awp.Done();
        }

        public void AnimateInAw(Await awp, string name)
        {
            new Await()
                .AddAw(SlideInByNameAw, name)
                .Commit(awp);
        }

        public void RedrawAw(Await awp, Truple tu)
        {
            tu.Element.Find("dt")
                .Each(
                    delegate(int i, Element domEl)
                    {
                        jQueryObject ths = jQuery.FromElement(domEl);
                        ths.Html(Redraw(ths.GetHtml()));
                        return true;
                    }
                )
                ;
        }

        public string Redraw(string txt)
        {
            txt = txt.Replace("%alias%", Strings.ParaCase(Master.Profile.MyAlias));
            return txt;
        }

    }
}
